package com.example.controller;

import com.example.entity.Shop;
import com.example.service.ShopService;
import com.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    ShopService shopService;

    @GetMapping("/getAll")
    public Result getAll(String searchName) {
        List<Shop> all = shopService.getAll(searchName);
        return Result.ok(all);
    }

    @GetMapping("/getShopById")
    public Result getShopById(@RequestParam Integer shopId) {
        return Result.ok(shopService.getShopById(shopId));
    }

    @GetMapping("/listShopByShopType")
    public Result listShopByShopType(@RequestParam String shopType) {
        List<Shop> result = shopService.listShopByShopType(shopType);
        return Result.ok(result);
    }

}
